<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'u_login.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="css/jquery.ui.all.css">
	<script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
	<script type="text/javascript" src="js/jquery-ui-1.8.15.custom.min.js"></script>
	<script type="text/javascript" src="js/slide.js"></script>
	<script type="text/javascript">
		function login(){
			var name = $("#i_name").val();
			var pass = $("#i_pass").val();
			//$.post("userlogin",{name:name,pass:pass},function(){
				
			//});
			location.href="userlogin?user="+name+"&pass="+pass;
		}
		$.fx.speeds._default = 1000;
		$(function() {
			$( "#dialog" ).dialog({
				autoOpen: false,
				show: "blind",
				hide: "explode"
			});
			$( "#repairpass" ).dialog({
				autoOpen: false,
				show: "blind",
				hide: "explode"
			});
			
			$( "#opener" ).click(function() {
				$( "#dialog" ).dialog( "open" );
				return false;
			});
			$( "#rpass" ).click(function() {
				$( "#repairpass" ).dialog( {
					autoOpen: true,
					height:170,
					width: 350
				});
				return false;
			});
			
		});
		function checkpass(){
			var p1 = $("#p1").val();
			var p2 = $("#p2").val();
			if(p1.length < 3 || p2.length < 3 || p1 != p2){
				alert("密码输入不一致或者小于3位");
				return false;
			}
		}
		
		function destory(){
			location.href="userlogin?des=0";
		}
		
		$(document).keydown(function(event){
			if(event.keyCode == 13){
				login();
			}
		}); 

	</script>
  </head>
  
  <body style="background-color:#FFFFCC;">
  	<center><font color="red" size = "5">点餐系统 v1.2</font></center>
    <%if(request.getAttribute("result") != null){ %>
  	<center><font color="red">${result }</font></center>	
  	<%} %>
  	<%if(request.getSession().getAttribute("user") == null){  %>
    <center>
    	<table>
    		<tr>
    			<td>用户名：</td>
    			<td><input type="text" name="user" id="i_name" /></td>
    		</tr>
    		<tr>
    			<td>密 码：</td>
    			<td><input type="password" name="pass" id="i_pass" /></td>
    		</tr>
    		<tr>
    			<td></td>
    			<td><input type="button" value="登录" onclick="login();"/><a href="index.jsp">注册</a></td>
    		</tr>
    	</table>
    </center>
    <%}else{ %>
    	<center>welcome <a href="" id="rpass" ><font size="5" color="red">${user.name }</font></a><a href="" onclick="destory();">注销</a></center>
    	<table align="center">
    		<tr>
    			<td><a  href="" id="opener">有趣</a></td>
    			<td><a  href="userlogin?user=${user.name }&pass=${user.pass }">点餐</a></td>
    			<td><a  href="orderfood">今日点餐</a></td>
    			<td><a href="note.txt">查看更新信息</a></td>
    		</tr>	
    	</table>
    	<div id="dialog" title="开心一下">
			<p>早晨，你醒来，枕边躺着一只断气的蚊子，旁边有一封遗书：我奋斗了一夜，也没能刺破你的脸皮，它厚的让我无颜活在这个世上，主啊！请宽恕他吧，我是自杀的。 </p>
		</div>
		<div id="repairpass" title="修改用户密码">
			<form action="repairpass" onsubmit="return checkpass();" >
				新密码：<input type="password" id="p1" name="p1"/><br/>
				新密码：<input type="password" id="p2" name="p2"/>
				<input type="submit" value="修改密码" />
			</form>
		</div>
		
    <%} %>
    <center>
    	<div id="focusViwer">
		<div id="imgADPlayer"></div> 
		<script> 
		PImgPlayer.addItem( "<a href=http://www.xuekaifa.com/index1.html target=_blank style=color:#000;text-decoration:none;>范冰冰最新写真 华美逼人</a>", "http://www.xuekaifa.com/index1.html", "img/1_small.jpg"); 		
		PImgPlayer.addItem( "<a href=http://www.xuekaifa.com/index2.html target=_blank style=color:#000;text-decoration:none;>盛 宴</a>", "http://www.xuekaifa.com/index2.html", "img/2_small.jpg"); 		
		PImgPlayer.addItem( "<a href=http://www.xuekaifa.com/index3.html target=_blank style=color:#000;text-decoration:none;>安 静</a>", "http://www.xuekaifa.com/index3.html", "img/3_small.jpg"); 		
		PImgPlayer.addItem( "<a href=http://www.xuekaifa.com/index4.html target=_blank style=color:#000;text-decoration:none;>高圆圆登韩国芭莎 奢华贵气十足</a>", "http://www.xuekaifa.com/index4.html", "img/4_small.jpg"); 
		PImgPlayer.addItem( "<a href=http://www.xuekaifa.com/index5.html target=_blank style=color:#000;text-decoration:none;>性感主播柳岩 男人装写真回顾</a>", "http://www.xuekaifa.com/index5.html", "img/5_small.jpg"); 	
		PImgPlayer.init( "imgADPlayer", 300, 356+24 );   
		</script>
		</div>
    </center>
  </body>
</html>
